|
|
|
|
|
|
|
The INI filename is passed as the last parameter to the function. This must be a fully qualified path and filename, or the INI file must reside in the Windows directory. The GetPrivateProfileString() function returns the length of the data it finds. Therefore, you need to use the Left$() function to chop off the rest of the spaces after the data. |
|
|
|
|
|
|
|
|
WritePrivateProfileString |
|
|
|
|
|
|
|
|
If you need to write data into an INI file, you can call the WritePrivateProfileString() function. Once again, you need to store the contents of the text boxes into string variables and then pass those values to the WritePrivateProfileString() function. Heres the code: |
|
|
|
 |
|
|
|
|
Private Sub cmdSave_Click()
Dim lngRet As Long
Dim strIni As String
Dim strSection As String
Dim strKeyName As String
Dim strKeyValue As String
strIni = Trim$(txtConfig)
strSection = Trim$(txtSection)
strKeyName = Trim$(txtKeyName)
strKeyValue = Trim$(txtKeyValue)
lngRet = WritePrivateProfileString( _
strSection, _
strKeyName, _
strKeyValue, _
strIni)
End Sub |
|
|
|
|
|
|
|
|
You can also retrieve all key names and values under a given section with the API call GetPrivateProfileSection(). Youll use this API call after youve wrapped the INI file information into a class module, later in this chapter. |
|
|
|
|
|